from datetime import datetime
from django import template
register = template.Library() # 1、实例化库

@register.filter(name='timefmt') # 3、注册过滤器
def timefmt(value): # 2、具体实现过滤器
    """将时间戳转换为datetime类型的时间"""
    return datetime.fromtimestamp(value)
@register.filter(name='cpu_val_fmt')
def cpu_val_fmt(value):
    return round(value/1000,2)